package com.yanqu.road.entity.config.goods;

import com.yanqu.road.utils.property.Property;
import com.yanqu.road.utils.property.PropertyHelper;
import com.yanqu.road.utils.string.StringUtils;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

public class MallInfo {
    /**
     * 编号
     */
    private int mallId;
    /**
     * 充值项编号
     */
    private int rechargeId;
    /**
     * 商店类型，商城、联盟商店等
     */
    private int shopType;
    /**
     * 商品名称
     */
    private String mallName;
    /**
     * 类别
     */
    private int category;
    /**
     * 道具信息
     */
    private String reward;
    private Property rewardProp;
    /**
     * 价格
     */
    private String price;
    /**
     * 递增价格
     */
    private int priceAdd;
    /**
     * 首充双倍
     */
    private boolean firstDouble;
    /**
     * 限购数量
     */
    private int limitBuyCount;
    /**
     * 排序
     */
    private int sort;
    /**
     * 限购类型
     */
    private int limitBuyType;
    /**
     * 返还元宝
     */
    private long returnIngots;
    /**
     * 参数
     */
    private String param;
    /**
     * 客户端埋点
     */
    private String pointSign;
    /**
     * 原价
     */
    private String oldPrice;
    /**
     * 客户端是否显示
     */
    private boolean isShow;
    /**
     * 活动编号
     */
    private int activityId;
    /**
     * 拓展参数
     */
    private String extendParam;
    /**
     * vip限制
     */
    private int vipLimit;
    /**
     * 限购参数(type;score)
     * type:1 今日积分
     * type:2 累计积分
     */
//    private String buyLimitParam;
    /**
     * 商品付费项编号
     */
    private String shopId = "";
    private String buyLimitParam;
    private String activityType = "";

    //是否可以购买,0不需要判断，其他具体判断
    private String canBuyParam = "0";

    //系统解锁限制  配置了对应的系统解锁才可以购买 0不判断
    private List<Integer> systemLimit = new ArrayList<>();

    // 0或当前channelId才会存到内存
    private int channelId = 0;

    private int mallMarkId;                     //商品标识编号，记录用

    private int reSetTime;

    //是否需要弹窗
    private int needRemind;

    //折扣，千分比。向上取证，0表示无折扣
    private int discount;

    private int isSpecial;

    //性价比
    private int costPerformance = 0;

    public MallInfo() {
    }

    public int getMallId() {
        return mallId;
    }

    public void setMallId(int mallId) {
        this.mallId = mallId;
    }

    public int getRechargeId() {
        return rechargeId;
    }

    public void setRechargeId(int rechargeId) {
        this.rechargeId = rechargeId;
    }

    public int getShopType() {
        return shopType;
    }

    public void setShopType(int shopType) {
        this.shopType = shopType;
    }

    public String getMallName() {
        return mallName;
    }

    public void setMallName(String mallName) {
        this.mallName = mallName;
    }

    public int getCategory() {
        return category;
    }

    public void setCategory(int category) {
        this.category = category;
    }

    public String getReward() {
        return reward;
    }

    public void setReward(String reward) {
        this.reward = reward;
    }

    public String getPrice() {
        return price;
    }

    public void setPrice(String price) {
        this.price = price;
    }

    public int getPriceAdd() {
        return priceAdd;
    }

    public void setPriceAdd(int priceAdd) {
        this.priceAdd = priceAdd;
    }

    public boolean isFirstDouble() {
        return firstDouble;
    }

    public void setFirstDouble(boolean firstDouble) {
        this.firstDouble = firstDouble;
    }

    public int getLimitBuyCount() {
        return limitBuyCount;
    }

    public void setLimitBuyCount(int limitBuyCount) {
        this.limitBuyCount = limitBuyCount;
    }

    public int getSort() {
        return sort;
    }

    public void setSort(int sort) {
        this.sort = sort;
    }

    public int getLimitBuyType() {
        return limitBuyType;
    }

    public void setLimitBuyType(int limitBuyType) {
        this.limitBuyType = limitBuyType;
    }

    public long getReturnIngots() {
        return returnIngots;
    }

    public void setReturnIngots(long returnIngots) {
        this.returnIngots = returnIngots;
    }

    public String getParam() {
        return param;
    }

    public void setParam(String param) {
        this.param = param;
    }

    public String getPointSign() {
        return pointSign;
    }

    public void setPointSign(String pointSign) {
        this.pointSign = pointSign;
    }

    public String getOldPrice() {
        return oldPrice;
    }

    public void setOldPrice(String oldPrice) {
        this.oldPrice = oldPrice;
    }

    public boolean isShow() {
        return isShow;
    }

    public void setShow(boolean show) {
        isShow = show;
    }

    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        this.activityId = activityId;
    }

    public Property getRewardProp() {
        return rewardProp;
    }

    public void setRewardProp(Property rewardProp) {
        this.rewardProp = rewardProp;
    }

    public String getExtendParam() {
        return extendParam;
    }

    public void setExtendParam(String extendParam) {
        this.extendParam = extendParam;
    }


    public int getVipLimit() {
        return vipLimit;
    }

    public void setVipLimit(int vipLimit) {
        this.vipLimit = vipLimit;
    }

    public String getShopId() {
        return shopId;
    }

    public void setShopId(String shopId) {
        this.shopId = shopId;
    }
    public String getBuyLimitParam() {
        return buyLimitParam;
    }

    public void setBuyLimitParam(String buyLimitParam) {
        this.buyLimitParam = buyLimitParam;
    }

    public String getActivityType() {
        return activityType;
    }

    public void setActivityType(String activityType) {
        this.activityType = activityType;
    }

    public String getCanBuyParam() {
        return canBuyParam;
    }

    public void setCanBuyParam(String canBuyParam) {
        this.canBuyParam = canBuyParam;
    }

    public List<Integer> getSystemLimit() {
        return systemLimit;
    }

    public void setSystemLimit(List<Integer> systemLimit) {
        this.systemLimit = systemLimit;
    }

    public int getChannelId() {
        return channelId;
    }

    public void setChannelId(int channelId) {
        this.channelId = channelId;
    }

    public int getMallMarkId() {
        return mallMarkId;
    }

    public void setMallMarkId(int mallMarkId) {
        this.mallMarkId = mallMarkId;
    }

    public int getReSetTime() {
        return reSetTime;
    }

    public void setReSetTime(int reSetTime) {
        this.reSetTime = reSetTime;
    }

    public int getNeedRemind() {
        return needRemind;
    }

    public void setNeedRemind(int needRemind) {
        this.needRemind = needRemind;
    }

    public int getDiscount() {
        return discount;
    }

    public void setDiscount(int discount) {
        this.discount = discount;
    }

    public int getIsSpecial() {
        return isSpecial;
    }

    public void setIsSpecial(int isSpecial) {
        this.isSpecial = isSpecial;
    }

    public int getCostPerformance() {
        return costPerformance;
    }

    public void setCostPerformance(int costPerformance) {
        this.costPerformance = costPerformance;
    }

    //获取一份复制
    public MallInfo getClone(){
        MallInfo mallInfo = new MallInfo();
        mallInfo.setMallId(mallId);
        mallInfo.setRechargeId(rechargeId);
        mallInfo.setShopType(shopType);
        mallInfo.setMallName(mallName);
        mallInfo.setCategory(category);
        mallInfo.setReward(reward);
        mallInfo.setPrice(price);
        mallInfo.setPriceAdd(priceAdd);
        mallInfo.setFirstDouble(firstDouble);
        mallInfo.setLimitBuyCount(limitBuyCount);
        mallInfo.setSort(sort);
        mallInfo.setLimitBuyType(limitBuyType);
        mallInfo.setReturnIngots(returnIngots);
        mallInfo.setParam(param);
        mallInfo.setPointSign(pointSign);
        mallInfo.setOldPrice(oldPrice);
        mallInfo.setShow(isShow);
        mallInfo.setActivityId(activityId);
        mallInfo.setRewardProp(rewardProp);
        mallInfo.setExtendParam(extendParam);
        mallInfo.setVipLimit(vipLimit);
        mallInfo.setShopId(shopId);
        mallInfo.setBuyLimitParam(buyLimitParam);
        mallInfo.setActivityType(activityType);
        mallInfo.setCanBuyParam(canBuyParam);
        mallInfo.setSystemLimit(systemLimit);
        mallInfo.setChannelId(channelId);
        mallInfo.setMallMarkId(mallMarkId);
        mallInfo.setReSetTime(reSetTime);
        mallInfo.setNeedRemind(needRemind);
        mallInfo.setDiscount(discount);
        mallInfo.setIsSpecial(isSpecial);
        mallInfo.setCostPerformance(costPerformance);
        return mallInfo;
    }

    public MallInfo(ResultSet rs ) throws SQLException {
        this.setActivityId(rs.getInt("activityId"));
        this.setMallId(rs.getInt("id"));
        this.setRechargeId(rs.getInt("rechargeId"));
        this.setMallName(rs.getString("name"));
        this.setShopType(rs.getInt("shopType"));
        this.setCategory(rs.getInt("category"));
        this.setReward(rs.getString("reward"));
        this.setRewardProp(PropertyHelper.parseStringToProperty(this.getReward()));
        this.setPrice(rs.getString("price"));
        this.setPriceAdd(rs.getInt("priceAdd"));
        this.setFirstDouble(rs.getBoolean("isDouble"));
        this.setLimitBuyType(rs.getInt("buyLimitType"));
        this.setLimitBuyCount(rs.getInt("buyLimit"));
        this.setSort(rs.getInt("sort"));
        this.setReturnIngots(rs.getInt("returnIngots"));
        this.setParam(rs.getString("param"));
        this.setPointSign(rs.getString("pointSign"));
        this.setOldPrice(rs.getString("oldPrice"));
        this.setShow(rs.getBoolean("isShow"));
        this.setExtendParam(rs.getString("extendParam"));
        this.setVipLimit(rs.getInt("vipLimit"));

        String shopId = rs.getString("shopId");
        this.setShopId(shopId == null ? "" : shopId);
        this.setBuyLimitParam(rs.getString("buyLimitParam"));
        this.setActivityType(rs.getString("acttype"));
        this.setCanBuyParam(rs.getString("canBuyParam"));
        List<Integer> systemList = new ArrayList<>();
        String systemLimitStr = rs.getString("systemLimit");
        if (!StringUtils.isNullOrEmpty(systemLimitStr) && !systemLimitStr.equals("0")) {
            systemList = StringUtils.stringToIntegerList(systemLimitStr, ";");
        }
        this.setSystemLimit(systemList);
        this.setMallMarkId(rs.getInt("mallMarkId"));
        this.setReSetTime(rs.getInt("reSetTime"));
        this.setNeedRemind(rs.getInt("needRemind"));
        this.setDiscount(rs.getInt("discount"));
        this.setIsSpecial(rs.getInt("isSpecial"));
        this.setCostPerformance(rs.getInt("costPerformance"));
    }
}
